import 'package:ladder_cash/app/com/view/common_view.dart';
import 'package:ladder_cash/app/key_mix.dart';
import 'package:liuxlcommon/view/extension_widget.dart';
import 'package:ladder_cash/app/app.dart';
import 'package:ladder_cash/app/com/service/burial_point_service.dart';
import 'package:ladder_cash/app/com/view/base_column.dart';
import 'package:ladder_cash/gen/assets.gen.dart';
import 'package:ladder_cash/generated/assets.dart' as myAssets;
import 'package:ladder_cash/generated/l10n.dart';
import 'package:ladder_cash/value/app_colors.dart';
import 'package:ladder_cash/value/app_lstyle.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:liuxlcommon/view/loading_view.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_box.dart';
import 'package:liuxlcommon/view/my_style.dart';
import '../../../config/super_theme.dart';
import '../../../library/src/logger.dart';
import '../../comm_key_def.dart';
import '../component/common.dart';
import '../component/decoration_bg.dart';
import 'authentication_logic.dart';

class BankInformationPage extends StatefulWidget {
  BankInformationPage({super.key});

  @override
  _AuthenticationPageState createState() => _AuthenticationPageState();
}

class _AuthenticationPageState extends State<BankInformationPage> {
  final logic = Get.find<AuthenticationLogic>();

  @override
  void initState() {
    super.initState();
    BurialPointService.start(BPoint.bank);
  }

  @override
  Widget build(BuildContext context) {
    Logger.d("BankInformationPage");
    return LoadingView(
        isPullDown: true,
        future: () => logic.getBankInfo(),
        datas: logic.authenticationInfo,
        onSuccess: () {
          if (logic.authenticationInfo != null) logic.update();
        },
        body: () => LColumn(
              lStyle: LStyle(),
              children: [logic.chooseList(type: CommKeyDef.bank), confirmBtn],
            ));
  }

  get confirmBtn => LColumn(lStyle: LStyle(css: '''
      width: 375px;
    background: #FFFFFF;
  height: 112px; 
    '''), children: [
        LSizeBoxHeight(16.w),
        Container(
          height: 53.w,
          padding: EdgeInsets.symmetric(horizontal: 16.w),
          child: commonBtn(S.current.next, callback: () {
            showConfirmDialog();
          }),
        ),
        LSizeBoxHeight(42.w)
      ]);

   showConfirmDialog(){
     Get.dialog(
         Column(
                children: [
                  Expanded(child: Container(),),
         Column(
           children: [
             Container(
               padding: EdgeInsets.symmetric(horizontal: 20.w),
               height: 30.w,
               child: Row(
                 mainAxisAlignment: MainAxisAlignment.end,
                 children: [
                   InkWell(
                     onTap: () {
                       Get.back();
                     },
                     child: Image.asset(
                       Assets.cer.cerClose.path,
                       width: 30.w,
                       height: 30.w,
                     ),
                   ),
                 ],
               ),
             ),
             30.lsh,
             Container(
               margin: EdgeInsets.symmetric(horizontal: 20.w),
               padding: EdgeInsets.only(
                   left: 20, right: 20.w, bottom: 10.w, top: 40.w),
               height: 397.w,
               decoration: BoxDecoration(
                   image: getDecorationBg(Assets.cer.cerPanBg.path)),
               child: Column(
                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
                 children: [
                   textBorder(S.current.pleaseConfirm,
                       fontWeight: FontWeight.w900,
                       fontsize: 24.sp,
                       color: SuperTheme.textTitltPrimary,
                       borderColor: Colors.black,
                       fontFamily: 'italic'),
                   Image.asset(
                     Assets.cer.cerBankPeople.path,
                     width: 109.w,
                     height: 127.w,
                   ),
                   middleFont(S.current.pleaseConfirmWhether,
                       fontsize: 16.sp),
                   Container(
                     height: 44.w,
                     width: 274.w,
                     alignment: Alignment.center,
                     decoration: BoxDecoration(
                         color: SuperTheme.inputBgPrimary,
                         borderRadius: getTopRadius(isAll: true)),
                     child: middleFont(logic.authenticationInfo!['items'.hx][2]
                     ['value'.hx]),
                   ),
                   Container(
                       height: 46.w,
                       child: commonBtn(S.current.confirm, callback: () {
                         Get.back();
                         logic.saveBankInfo();
                       })),
                 ],
               ),
             ),
           ],
         ),
                  Expanded(child: Container(),),
                ],
              ));
   }
}
